package chess;

/**
 *
 * @author Anthony Hilyard
 */
public class Knight extends Piece
{
    
    public Knight(int color)
    {
        pieceColor = color;
    }//end of constructor
    
    public int canMove(int sourceX, int sourceY, int destX, int destY)
    {
        // Return false if coordinates are outside of the board.
        if(sourceX < 0 || sourceX > 7 || sourceY < 0 || sourceY > 7 ||
                destX < 0 || destX > 7 || destY < 0 || destY > 7)
            return 0;
        
        // If the difference between X values is 2 and the difference between Y values is 1,
        // or vice-versa, this is a valid move.
        if(      (Math.abs(destX - sourceX) == 2 && Math.abs(destY - sourceY) == 1) ||
                 (Math.abs(destX - sourceX) == 1 && Math.abs(destY - sourceY) == 2)    )
            return 1;
        else
            return 0;
                    
    }//end of canMove
    
    public char getType()
    {
        return 'N';
    }//end of getType
    
    public static int getValue()
    {
        return 3;
    }//end of getValue
     
}//end of Knight
